﻿using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Net.Mail;
using SoftSource.Timecard.Web.DAL;

namespace SoftSource.Timecard.Web.Library
{
    public sealed class SendMessage
    {      
        public static void SendEmail(
            string password,
            string subject,
            string messageBody,
            string fromAddress,
            IEnumerable<string> toAddress,
            IEnumerable<string> ccAddress,
            bool seperateToAddresses)
        {
            // TODO: Send email
            //MailMessage message = new MailMessage();
            //SmtpClient client = new SmtpClient();

            //// Set the sender's address
            //message.From = new MailAddress(fromAddress);


            //if (ccAddress != null)
            //{
            //    foreach (string addr in ccAddress)
            //    {
            //        message.CC.Add(new MailAddress(addr));
            //    }
            //}

            //// Set the subject and message body text
            //message.Subject = subject;
            //message.Body = messageBody;
            //message.IsBodyHtml = false;

            //AuthenticationService auth = new AuthenticationService();
            //var user = auth.GetUser();

            //if (user == null)
            //    return;

            //string emailUsername = Users.GetUserEmail(user.UserID).Split('@').First();
            //string emailPassword = password;
            //client.Credentials = new NetworkCredential(emailUsername, emailPassword, "sftsrc.com");

            //if (seperateToAddresses)
            //{
            //    if (toAddress != null)
            //    {
            //        foreach (string addr in toAddress)
            //        {
            //            var mailAddr = new MailAddress(addr);
            //            message.To.Add(mailAddr);
            //            // Send the e-mail message
            //            client.Send(message);
            //            message.To.Remove(mailAddr);
            //        }
            //    }
            //}
            //else
            //{
            //    if (toAddress != null)
            //    {
            //        foreach (string addr in toAddress)
            //        {
            //            message.To.Add(new MailAddress(addr));
            //        }
            //    }

            //    // Send the e-mail message
            //    client.Send(message);
            //}
        }
    }
}
